<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Zombie Navigator: Module: zombie/async</title><script src="scripts/prettify/prettify.js"> </script><link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"><link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"></head><body><div id="main"><h1 class="page-title">Module: zombie/async</h1><section><header></header><article><div class="container-overview"><div class="description">Zombie Navigator API (ZAPI) documentation</div><dl class="details"><dt class="tag-version">Version:</dt><dd class="tag-version"><ul class="dummy"><li>0.4.0</li></ul></dd><dt class="tag-copyright">Copyright:</dt><dd class="tag-copyright"><ul class="dummy"><li>Copyright © 2015  Zombie Navigator Developers
<br /><br />
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU Affero General Public License as
	published by the Free Software Foundation, either version 3 of the
	License, or (at your option) any later version.
<br /><br />
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Affero General Public License for more details.
<br /><br />
	You should have received a copy of the GNU Affero General Public License
	along with this program.  If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.
<br /><br />
	The latest version of the GNU AGPL should be available here:
<a href="https://www.gnu.org/licenses/agpl.html">https://www.gnu.org/licenses/agpl.html</a></li></ul></dd><dt class="tag-license">License:</dt><dd class="tag-license"><ul class="dummy"><li>AGPL-3.0+</li></ul></dd><dt class="tag-source">Source:</dt><dd class="tag-source"><ul class="dummy"><li><a>async.jsdoc</a>, <a>line 1</a></li></ul></dd></dl></div><h3 class="subsection-title">Methods</h3><h4 class="name" id="~delay"><span class="type-signature">(inner) </span>delay<span class="signature">(s)</span><span class="type-signature"> &rarr; {Promise}</span></h4><div class="description">
    Asynchronous sleep using Promise
</div><h5>Parameters:</h5><table class="params"><thead><tr><th>Name</th><th>Type</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>s</code></td><td class="type"><span class="param-type">number</span></td><td class="description last">The number of seconds to sleep for</td></tr></tbody></table><dl class="details"><dt class="tag-source">Source:</dt><dd class="tag-source"><ul class="dummy"><li><a>async.jsdoc</a>, <a>line 52</a></li></ul></dd></dl><h5>Returns:</h5><dl><dt>
        Type
</dt><dd><span class="param-type">Promise</span></dd></dl><h5>Example</h5><pre class="prettyprint"><code>const {delay} = require('zombie/async');
</code></pre><h4 class="name" id="~run"><span class="type-signature">(inner) </span>run<span class="signature">(genFunction)</span><span class="type-signature"> &rarr; {Promise}</span></h4><div class="description">
    Run a generator as a coroutine using Promise
</div><h5>Parameters:</h5><table class="params"><thead><tr><th>Name</th><th>Type</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>genFunction</code></td><td class="type"><span class="param-type">function</span></td><td class="description last">Generator (coroutine) to run</td></tr></tbody></table><dl class="details"><dt class="tag-source">Source:</dt><dd class="tag-source"><ul class="dummy"><li><a>async.jsdoc</a>, <a>line 79</a></li></ul></dd></dl><h5>Returns:</h5><dl><dt>
        Type
</dt><dd><span class="param-type">Promise</span></dd></dl><h5>Example</h5><pre class="prettyprint"><code>const {run} = require('zombie/async');
run(function* () {
	try {
		let result = yield new Promise(...);
	} catch (e) {
		// rejected
	}
	throw new Error();
})
.then(function (result) {
	// generator is finished
})
.catch(function (e) {
	// an error in generator
});
</code></pre></article></section></div><nav><h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-zombie_async.html">zombie/async</a></li><li><a href="module-zombie_webbrowser.html">zombie/webbrowser</a></li><li><a href="module-zombie_zombie.html">zombie/zombie</a></li></ul><h3>Classes</h3><ul><li><a href="module-zombie_webbrowser-Window.html">Window</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-zombie_zombie-console.html">console</a></li><li><a href="module-zombie_zombie-zombie.html">zombie</a></li></ul></nav><br class="clear"><footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.3</a></footer><script> prettyPrint(); </script></body></html>
